class Configuration
	def initialize(log, fileName)
        @fileName = fileName
        @data = {}
        @data['sources'] = Array.new()
        @data['exec'] = {}
        @data['targets'] = {}
        currentCategory = currentData = nil
        log.debug 'Parsing configuration file [' + fileName + '].'
        File.open @fileName, 'r' do |file|
        	file.read.each do |line|
        		line = line.chomp
        		if(line.match(/^#/) == nil)
        			if(line.match(/^\[/) != nil)
        				line = line.gsub(/[\[\]]/, '')
        				currentCategory = line
        				currentData = @data[line]
        			elsif(/\S/ !~ line)
					    # ignore empty lines
        			else
						if(currentCategory == 'exec')
							currentData[line.sub(/:.*/, '')] = line.sub(/.*: /, '')
						elsif(currentCategory == 'targets')
							currentData[line.sub(/ .*/, '')] = line.sub(/.* /, '')
						else # currentCategory == 'sources'
              # TODO implement wildcard feature!
							currentData.push(line)
						end
        			end
        		end
        	end
        end
	end
	def data
		@data
	end
end